package com.cmict.data.system.enums.social;

import cn.hutool.core.util.ArrayUtil;
import com.cmict.data.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 社交平台的类型枚举
 *
 * @author awesome
 */
@Getter
@AllArgsConstructor
public enum SocialTypeEnum implements IntArrayValuable {

    GITEE(10, "GITEE"),
    DINGTALK(20, "DINGTALK"),

    WECHAT_ENTERPRISE(30, "WECHAT_ENTERPRISE"),
    WECHAT_MP(31, "WECHAT_MP"),
    WECHAT_OPEN(32, "WECHAT_OPEN"),
    WECHAT_MINI_PROGRAM(33, "WECHAT_MINI_PROGRAM"),
    ;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(SocialTypeEnum::getType).toArray();

    /**
     * 类型
     */
    private final Integer type;
    /**
     * 类型的标识
     */
    private final String source;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static SocialTypeEnum valueOfType(Integer type) {
        return ArrayUtil.firstMatch(o -> o.getType().equals(type), values());
    }

}
